'use strict';
var app = angular.module('WDCC', ['ngAnimate', 'ngCookies', 'ngResource', 'ngFileUpload', 'ngRoute', 'ngSanitize', 'ngTouch', 'toastr', 'chart.js']);

app.config(function ($controllerProvider, $compileProvider, $filterProvider, $provide) {

    app.register = {
        controller: $controllerProvider.register,
        directive: $compileProvider.directive,
        filter: $filterProvider.register,
        factory: $provide.factory,
        service: $provide.service
    };
});


//eChart封装
app.directive('eCharts', function () {
    return {
        restrict: 'AE',
        scope: {
            source: '=',
            option:'='
        },
        template: '<div></div>',
        controller: function ($scope) {
        },
        link: function (scope, element, data) {
            var chart = element.find('div')[0];
            var parent = element['context'];
            //    console.log(parent.clientHeight+":"+parent.clientWidth);
            chart.style.width = parent.clientWidth + 'px';
            chart.style.height = parent.clientHeight + 'px';

            var myChart = echarts.init(chart);
            var option = scope.option;
            myChart.setOption(option);
            myChart.resize();
        }
    };
})


app.directive('repeatFinish', function () {
    return {
        link: function (scope, element, attr) {
            if (scope.$last == true) {
                scope.$eval(attr.repeatFinish)
            }
        }
    };
});


//设置路由器


app.config(function ($locationProvider, $routeProvider) {
    $locationProvider.hashPrefix('!');
    $routeProvider.when('/Welcom', {
        templateUrl: 'html/WelcomMgmt/index.html'
    }).when('/', {
        templateUrl: 'html/Login.html', //登录页
        controller: 'LoginCtrl'
    }).when('/homePage', {
        templateUrl: 'html/homePage/index.html' //跳转到检查医嘱js 页面
    }).when('/DataCenter', {
        templateUrl: 'html/DataCenter/index.html' //跳转到检查医嘱js 页面
    }).otherwise({
        redirectTo: '/NoFunction'
    });

});


app.run(function ($rootScope, $interval, $location, $cookieStore, $http, toastr, pageParam, $window) {
        $rootScope.UserBean = {};
        $rootScope.app = {
            name: '"两癌"筛查与妇女病防治中心机构端',
            copyright: '版权所有 医药网（北京）科技发展有限公司',
            ctx: '/WDCC/',
            ath: '/WDCC/WDCCService/',
            Authentication: null
        };


        //菜单 点击事件
        $rootScope.MenuClick = function (v) {
            console.log(v)
            $location.path("/" + v).search(""); //跳转到对应文件夹下

        };
    }
);

